<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Skew Box</title>
</head>

<body>
  <div class="container">
    <div class="item active" style="--index: 0">
      <div class="title">年</div>
    </div>
    <div class="item" style="--index: 1">
      <div class="title">月</div>
    </div>
    <div class="item" style="--index: 2">
      <div class="title">周</div>
    </div>
    <div class="item" style="--index: 3">
      <div class="title">日</div>
    </div>
  </div>

  <style>
    :root {
      --size: 32px;
      --skew-degree: 20deg;
      --step-length: 4;
      --theme-color: #0ad6ef;
      --background-color: #04203e;

      background-color: var(--background-color);
    }

    .container {
      overflow: hidden;
      height: var(--size);
      position: relative;
      border: 1px solid var(--theme-color);
      border-top: 0;
      border-right: 0;
    }

    .container .item {
      position: absolute;
      border: 1px solid var(--theme-color);
      left: calc((var(--index) * var(--step-length) - 1) * var(--size));
      transform-origin: top left;
      transform: skewX(var(--skew-degree));
      color: var(--theme-color);
      background-color: var(--background-color);
      height: var(--size);
      width: calc(var(--step-length) * var(--size));
    }

    .container .item.active {
      color: var(--background-color);
      background-color: var(--theme-color);
    }

    .container .item .title {
      transform: skewX(calc(-1 * var(--skew-degree))) translateX(calc(var(--size) / 2 * var(--step-length)));
      line-height: var(--size);
    }

  </style>
</body>

</html>
